<?php
namespace Mobile\Controller;
use Think\Controller;
class AppController extends Controller {


    protected $c_info;
    protected $u_info;

    function __construct()
    {
        parent::__construct();
        $this->c_info;
        $this->M_company = M('Company');
        $this->M_member = M('Member');
        $this->cid = I('post.cid',0,'intval');
        $this->where = $this->get_where();
        $this->uid = $this->get_uid();
//        $this->uid = 2;
        $this->login();
    }

    protected function get_uid(){
        if($this->cid == ''){
            $this->re_json(array('errMsg'=>'请带商家参数！'));
        } else {
            $tui_key = I('post.kui_key');
            if ($tui_key) {
                $this->c_info = $this->M_company->find($this->cid);
                $uid = $this->u_info = $this->M_member->where("kui_key = '".$tui_key."'")->find();
                //p($this->u_info);
                if($uid){
                    return $uid;
                }else{
                    $this->re_json(array('errMsg'=>'重新登录啊'));
                }
            } else {
                $this->re_json(array('errMsg'=>'无kui_key'));
            }
        }
    }

    private function login(){
        if(!$this->uid){
            die($this->ajaxReturn(array('errMsg'=>'对不起，您没有登录！')));
        }
    }

    protected function get_where(){
        $where = 'c_id =3 ';
        return $where;
    }

    protected function re_json($data){
        //p($data);
        die($this->ajaxReturn($data));
    }




}
